from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o-mini")
template = """Write a {adjective} poem about {subject}."""
prompt = PromptTemplate(template=template, input_variables=["adjective", "subject"])

# 使用新的RunnableSequence语法替代已弃用的LLMChain
chain = prompt | model
result = chain.invoke({"adjective": "sad", "subject": "ducks"})
print(result.content)
